$(function () {
    /*发布判断*/
    $("#addHouse").click(function () {
        if ($("#title").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('房屋名称不能为空');
            return;
        }
        if ($("#shi").val() == "" || $("#ting").val()=="") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入房屋户型');
            return;
        }
        var yzFormat = /^[0-9]$/;
        if(!yzFormat.test($("#shi").val().trim())){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入正确室数');
            return;
        }
        if(!yzFormat.test($("#ting").val().trim())){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入正确厅数');
            return;
        }

        if ($("#ftype_id").val() == "" || $("#ftype_id").val() == "0") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('房屋类型不能为空');
            return;
        }
        if ($("#price").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入房屋价格');
            return;
        }

        if(isNaN($("#price").val().trim())){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入正确的房屋价格');
            return;
        }
       if ($("#yajin").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入房屋押金(数字-.-)');
            return;
        }
        if(isNaN($("#yajin").val().trim())){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入正确房屋押金(数字-.-)');
            return;
        }
        if ($("#area").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入房屋面积');
            return;
        }
        if(isNaN($("#yajin").val())){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入正确房屋面积(数字-.-)');
            return;
        }
        if ($("#facility").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请选择房屋具有的设施');
            return;
        }
        if ($(".imgname").length < 1) {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请上传您的房屋图片');
            return;
        }
        if ($("#expressArea").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请选择您所在城市');
            return;
        }

       var pattern=/select|update|delete|truncate|join|union|exec|insert|drop|count|’|"|;|>|<|%/i;
        if ($("#xxaddress").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入您房屋详细地址');
            return;
        }
        if(pattern.test($("#xxaddress").val())){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('房屋地址不能特殊字符噢');
            return;
        }
        if ($("#traffic").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入您附近的交通');
            return;
        }
        if(pattern.test($("#traffic").val())){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('交通不能输入特殊字符噢');
            return;
        }
        if ($("#introduce").val() == "") {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请输入您房屋的详细介绍');
            return;
        }
        if(pattern.test($("#introduce").val())){
            var layer = layui.layer
                , form = layui.form;
            layer.msg('详细介绍不能输入特殊字符噢');
            return;
        }
        if (!$("#check").prop("checked") ==true) {
            var layer = layui.layer
                , form = layui.form;
            layer.msg('请阅读并同意原宿协议');
            return;
        }
        $("#fabu").submit();
    })

    /*给li添加check属性值*/
    $("#ul li").each(function () {
        $("#ul li").attr("check","1");
    })
    /*li check属性判断复选框选中状态*/
    $("#ul li").click(function(){
        var check = $(this).attr("check");
        if(check=="1"){
            $(this).children("input").prop("checked",true);
            $(this).attr("check","2");
        }else{
            $(this).children("input").prop("checked",false);
            $(this).attr("check","1")
        }
    })
    /*切换发布跟设施页面*/
    $("#showFacility").click(function(){
        $("#show").hide();
        $("#hidden").show()
    })
})